#pragma once
#include <iostream>
#include <string>

enum
{
    EXITCODE = 0,
    DIVZERO,
    MODZERO
};

class Task
{
public:
    Task()
    {}
    
    Task(int x, int y, char oper, int exitcode_ = EXITCODE) : _data1(x), _data2(y), _oper(oper), exitcode(exitcode_)
    {}

    void run()
    {

        switch (_oper)
        {
        case '+':
            result = _data1 + _data2;
            break;
        case '-':
            result = _data1 - _data2;

            break;
        case '*':
            result = _data1 * _data2;

            break;
        case '/':
            if(_data1 == 0 | _data2 == 0)
            {
                exitcode = DIVZERO;
            }
            else
            {
                result = _data1 / _data2;
            }

            break;
        case '%':
            if(_data1 == 0 | _data2 == 0)
            {
                exitcode = MODZERO;
            }
            else
            {
                result = _data1 % _data2;
            }
            
            break;
        default:
            std::cout << "Symbol mismatch!" << std::endl;
            break;
        }
        std::cout << _To_String() << " = " << result << std::endl;

        // std::cout << "a + b =  " << _a + _b << std::endl;
    }

    std::string _To_String()
    {
        std::string str;
        str += "[exitcode: ";
        str += std::to_string(exitcode);
        str += "]";
        str += " ";
        str += std::to_string(_data1);
        str += " ";
        str += _oper;
        str += " ";
        str += std::to_string(_data2);

        return str;
    }

    void GetTask()
    {
        std::cout << _data1 << " " << _oper << " " << _data2 << " = ?" << std::endl;
    }

    void operator()()
    {
        run();
    }

    ~Task()
    {}

private:
    int _data1;
    int _data2;
    char _oper;

    int exitcode;
    int result;
};